/***************************************************************************
*  main.cpp
*
*  July 2007
*  Copyright  2007  RuijinZheng,China
*  Email mebetop@126.com
****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
#include <QApplication>
#include <QTranslator>
#include <QObject>
#include <qnamespace.h>
#include <QIcon>
#include <QSystemLocale>
#include <QLocale>
#include <QFileInfo>
#include <QMessageBox>
#include <QTextCodec>
#include "Mainwidget.h"
#include "Trayicon.h"
using namespace Qt;
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
 //   QTextCodec::setCodecForLocale(QTextCodec::codecForLocale());
    QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    QSystemLocale syslocal;
    QLocale local = syslocal.fallbackLocale();
    QString localefile("/usr/share/netflea/locale/language.");
    localefile+=local.name();
    QFileInfo filetest(localefile);
    QTranslator translator;
    if((!filetest.exists())&&(!(local.name().startsWith("en_")))){
         QMessageBox::warning(0, QObject::tr("Attention"),
              QObject::tr("Can not find locale file matching your locale, use English instead."));

    }
    else{

         translator.load(localefile);
         app.installTranslator(&translator);
    }
    MainWidget main;
    main.show();

    QIcon icon(":/icons/trayicon.png");
    Trayicon systray(icon);
    systray.show();
  //  QObject::connect(&main,SIGNAL(readytostartlisten()),&systray,SLOT(starListenThread()));

    return app.exec();
}

